// TempletOptionPage.cpp : implementation file
//

#include "stdafx.h"
#include "kwclientcore.h"
#include "TempletOptionPage.h"

#include "GUIBaseLib\TopPropertySheet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTempletOptionPage property page

IMPLEMENT_DYNCREATE(CTempletOptionPage, CPropertyPage)

CTempletOptionPage::CTempletOptionPage() : CPropertyPage(CTempletOptionPage::IDD)
{
	//{{AFX_DATA_INIT(CTempletOptionPage)
	m_bShare = FALSE;
	//}}AFX_DATA_INIT
  m_dwOptions = 0;
}

CTempletOptionPage::~CTempletOptionPage()
{
}

void CTempletOptionPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTempletOptionPage)
	DDX_Check(pDX, IDC_TEMPLETOPTIONPAGE_SHARE, m_bShare);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTempletOptionPage, CPropertyPage)
	//{{AFX_MSG_MAP(CTempletOptionPage)
	ON_BN_CLICKED(IDC_TEMPLETOPTIONPAGE_OPTION0, OnModified)
	ON_BN_CLICKED(IDC_TEMPLETOPTIONPAGE_OPTION1, OnModified)
	ON_BN_CLICKED(IDC_TEMPLETOPTIONPAGE_OPTION2, OnModified)
	ON_BN_CLICKED(IDC_TEMPLETOPTIONPAGE_OPTION3, OnModified)
	ON_BN_CLICKED(IDC_TEMPLETOPTIONPAGE_OPTION4, OnModified)
	ON_BN_CLICKED(IDC_TEMPLETOPTIONPAGE_OPTION5, OnModified)
	ON_BN_CLICKED(IDC_TEMPLETOPTIONPAGE_OPTION6, OnModified)
	ON_BN_CLICKED(IDC_TEMPLETOPTIONPAGE_OPTION7, OnModified)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTempletOptionPage message handlers

BOOL CTempletOptionPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
  for (int i = 0;i < 8;i++) 
  {
    CheckDlgButton(IDC_TEMPLETOPTIONPAGE_OPTION0+i, m_dwOptions&(1<<i));
  }
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CTempletOptionPage::OnModified() 
{
	// TODO: Add your control notification handler code here
	SetModified();
}

BOOL CTempletOptionPage::OnApply() 
{
	// TODO: Add your specialized code here and/or call the base class
  UpdateExtendedData();

  ((CTopPropertySheet *)GetParent())->SetbModified();

	return CPropertyPage::OnApply();
}

void CTempletOptionPage::UpdateExtendedData()
{
  m_dwOptions = 0;
  for (int i = 0;i < 8;i++) 
  {
    if (IsDlgButtonChecked(IDC_TEMPLETOPTIONPAGE_OPTION0+i)) m_dwOptions |= (1<<i);
  }
}
